home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / cenvid9.zip / KBDRATE.BAT < prev    next >
DOS Batch File  |  1994-03-04  |  2KB  |  58 lines

  1. @echo OFF
  2. REM ********************************************************************
  3. REM *** KbdRate.bat - CEnvi sample file which will, on most systems, ***
  4. REM *** ver.1         set the keyboard typematic values.             ***
  5. REM ********************************************************************
  6. @cenvi %0.bat %1 %2 %3
  7. GOTO CENVI_EXIT
  8.  
  9. #define MIN_DELAY    1
  10. #define MAX_DELAY    4
  11. #define MIN_RATE     2
  12. #define MAX_RATE     30
  13.  
  14. main(argc,argv)
  15. {
  16.    if ( argc != 3 )
  17.       Instructions()
  18.    else {
  19.       // check input values for valid ranges
  20.       delay = atoi(argv[1]);
  21.       rate = atoi(argv[2]);
  22.       if ( delay < MIN_DELAY  ||  MAX_DELAY < delay
  23.         || rate < MIN_RATE  ||  MAX_RATE < rate ) {
  24.          printf("\aInvalid input value; enter /? for instructions\n");
  25.       } else {
  26.          SetDelayAndRate(delay,rate);
  27.       }
  28.    }
  29. }
  30.  
  31. SetDelayAndRate(delay,rate)   // delay in 1/4 sec; rate in reps/sec
  32. {
  33.    // set delay value
  34.    reg.bh = delay - 1;
  35.    // set table for which delay corresponds to the rate
  36.    DelayApproximations = {     31, 26, 23, 20, 18, 17, 15, 13, 12,
  37.                            11, 10,  9,  9,  8,  7,  6,  5,  5,  4,
  38.                             3,  3,  2,  2,  2,  1,  1,  1,  0,  0 };
  39.    reg.bl = DelayApproximations[rate-MIN_RATE];
  40.    // finall call dos interrupt 16, function 03 to set delay and rate
  41.    reg.ax = 0x0305;
  42.    interrupt(0x16,reg);
  43. }
  44.  
  45. Instructions()
  46. {
  47.    printf("\n")
  48.    printf("KbdRate - Set keyboard typematic rates.  This works with most BIOS's\n")
  49.    printf("\n")
  50.    printf("USAGE: KbdRate Delay Rate\n")
  51.    printf("\n")
  52.    printf("Where: Delay - Delay in 1/4 seconds before repeat; min = %d, max = %d\n",MIN_DELAY,MAX_DELAY);
  53.    printf("       Rate  - Repetitions of key per second; min = %d, max = %d\n",MIN_RATE,MAX_RATE);
  54.    printf("\n")
  55. }
  56.  
  57. :CENVI_EXIT
  58.